<template>
	<view class="container">
		<!-- 顶部安全区域占位 -->
		<!-- <view class="status-bar"></view> -->

		<!-- 顶部导航栏 -->
		<!-- <uni-nav-bar left-icon="left" title="订单详情" backgroundColor="#2a8cff" color="#fff" @clickLeft="goBack" /> -->

		<!-- 主要内容区域 -->
		<view class="content">
			<!-- 订单状态卡片 -->
			<view class="status-card">
				<view class="status-header">
					<view class="status-icon" :class="isVerified ? 'verified' : 'pending'">
						<uni-icons :type="isVerified ? 'checkmarkempty' : 'clock'" size="24"
							:color="isVerified ? '#52c41a' : '#faad14'"></uni-icons>
					</view>
					<view class="status-info">
						<text class="status-text">{{ isVerified ? '已核销' : '待核销' }}</text>
						<text class="status-desc">{{ isVerified ? '订单已完成核销' : '等待确认核销' }}</text>
					</view>
				</view>
				<view class="verify-code-section">
					<text class="code-label">核销码</text>
					<text class="code-value">MC1234-5678-9012</text>
				</view>
			</view>

			<!-- 车辆信息卡片 -->
			<view class="info-card">
				<view class="card-header">
					<uni-icons type="car" size="20" color="#2a8cff"></uni-icons>
					<text class="card-title">车辆信息</text>
				</view>
				<view class="vehicle-info">
					<text class="vehicle-text">奔驰FWE4 / 豫A98FH</text>
				</view>
			</view>

			<!-- 服务内容卡片 -->
			<view class="info-card">
				<view class="card-header">
					<uni-icons type="gear" size="20" color="#2a8cff"></uni-icons>
					<text class="card-title">服务内容</text>
				</view>
				<view class="service-list">
					<view class="service-item">
						<view class="service-info">
							<text class="service-name">车辆精洗</text>
							<text class="service-desc">专业清洗服务</text>
						</view>
						<text class="service-price">¥100</text>
					</view>
					<view class="service-item">
						<view class="service-info">
							<text class="service-name">车辆精洗附加费</text>
							<text class="service-desc">额外服务费用</text>
						</view>
						<text class="service-price">¥10</text>
					</view>
				</view>
			</view>

			<!-- 订单信息卡片 -->
			<view class="info-card">
				<view class="card-header">
					<uni-icons type="list" size="20" color="#2a8cff"></uni-icons>
					<text class="card-title">订单信息</text>
				</view>
				<view class="order-info-list">
					<view class="info-item">
						<text class="info-label">原价</text>
						<text class="info-value">¥110</text>
					</view>
					<view class="info-item">
						<text class="info-label">优惠</text>
						<text class="info-value discount">-¥20</text>
					</view>
					<view class="info-item total-item">
						<text class="info-label">实付金额</text>
						<text class="info-value total">¥90.00</text>
					</view>
					<view class="info-item">
						<text class="info-label">订单编号</text>
						<text class="info-value">1223233445</text>
					</view>
					<view class="info-item">
						<text class="info-label">预约时间</text>
						<text class="info-value">2023-03-18 19:00:00</text>
					</view>
					<view class="info-item">
						<text class="info-label">支付时间</text>
						<text class="info-value">2023-03-18 19:14:28</text>
					</view>
					<view class="info-item" v-if="isVerified">
						<text class="info-label">核销时间</text>
						<text class="info-value verified-time">{{ verifyTime }}</text>
					</view>
					<view class="info-item" v-else>
						<text class="info-label">核销时间</text>
						<text class="info-value unverify">未核销</text>
					</view>
				</view>
			</view>
		</view>

		<!-- 核销按钮 -->
		<view class="button-container">
			<button class="verify-btn" @click="confirmVerify" v-if="!isVerified">
				<uni-icons type="checkmarkempty" size="18" color="#fff"></uni-icons>
				<text>确认核销</text>
			</button>
			<button class="verified-btn" disabled v-else>
				<uni-icons type="checkmarkempty" size="18" color="#52c41a"></uni-icons>
				<text>已核销</text>
			</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 核销状态
				isVerified: false,
				// 核销时间
				verifyTime: ''
			};
		},
		onLoad(options) {
			// 可以从路由参数中获取订单ID
			if (options.orderId) {
				// 这里可以根据订单ID获取订单详情
				console.log('订单ID:', options.orderId);
			}
		},
		methods: {
			// 返回上一页
			goBack() {
				uni.navigateBack();
			},
			// 确认核销
			confirmVerify() {
				uni.showModal({
					title: '确认核销',
					content: '是否确认核销该订单？',
					success: (res) => {
						if (res.confirm) {
							// 执行核销操作
							this.processVerify();
						}
					}
				});
			},
			// 处理核销
			processVerify() {
				// 模拟核销过程
				setTimeout(() => {
					// 更新核销状态
					this.isVerified = true;

					// 记录核销时间
					const date = new Date();
					this.verifyTime = date.toLocaleString('zh-CN', {
						year: 'numeric',
						month: '2-digit',
						day: '2-digit',
						hour: '2-digit',
						minute: '2-digit',
						second: '2-digit',
						hour12: false
					}).replace(/\//g, '-');

					// 显示核销成功提示
					uni.showToast({
						title: '核销成功',
						icon: 'success',
						duration: 2000
					});
				}, 1000);
			}
		}
	};
</script>

<style>
	.container {
		background: linear-gradient(135deg, #2a8cff 0%, #2a8cff 100%);
		min-height: 100vh;
		display: flex;
		flex-direction: column;
	}

	/* 顶部安全区域 */
	.status-bar {
		height: var(--status-bar-height);
		background: linear-gradient(135deg, #2a8cff 0%, #2a8cff 100%);
	}

	/* 主要内容区域 */
	.content {
		flex: 1;
		padding: 20rpx;
	}

	/* 状态卡片 */
	.status-card {
		background-color: #fff;
		border-radius: 20rpx;
		padding: 30rpx;
		margin-bottom: 20rpx;
		box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.1);
	}

	.status-header {
		display: flex;
		align-items: center;
		margin-bottom: 25rpx;
	}

	.status-icon {
		width: 60rpx;
		height: 60rpx;
		border-radius: 50%;
		display: flex;
		align-items: center;
		justify-content: center;
		margin-right: 20rpx;
	}

	.status-icon.verified {
		background: linear-gradient(135deg, #52c41a 0%, #73d13d 100%);
	}

	.status-icon.pending {
		background: linear-gradient(135deg, #faad14 0%, #ffc53d 100%);
	}

	.status-info {
		flex: 1;
	}

	.status-text {
		font-size: 32rpx;
		font-weight: 600;
		color: #333;
		display: block;
		margin-bottom: 8rpx;
	}

	.status-desc {
		font-size: 24rpx;
		color: #666;
	}

	.verify-code-section {
		background: linear-gradient(135deg, #f0f2ff 0%, #e6f7ff 100%);
		border-radius: 12rpx;
		padding: 20rpx;
		text-align: center;
	}

	.code-label {
		font-size: 24rpx;
		color: #666;
		display: block;
		margin-bottom: 10rpx;
	}

	.code-value {
		font-size: 36rpx;
		color: #2a8cff;
		font-weight: 600;
		letter-spacing: 2rpx;
		font-family: 'Courier New', monospace;
	}

	/* 信息卡片 */
	.info-card {
		background-color: #fff;
		border-radius: 20rpx;
		padding: 30rpx;
		margin-bottom: 20rpx;
		box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.1);
	}

	.card-header {
		display: flex;
		align-items: center;
		margin-bottom: 25rpx;
		padding-bottom: 15rpx;
		border-bottom: 1px solid #f0f0f0;
	}

	.card-title {
		font-size: 30rpx;
		font-weight: 600;
		color: #333;
		margin-left: 12rpx;
	}

	/* 车辆信息 */
	.vehicle-info {
		padding: 20rpx;
		background: linear-gradient(135deg, #f6f8ff 0%, #f0f2ff 100%);
		border-radius: 12rpx;
	}

	.vehicle-text {
		font-size: 28rpx;
		color: #333;
		font-weight: 500;
	}

	/* 服务列表 */

	.service-item {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 20rpx 0;
		border-bottom: 1px solid #f5f5f5;
	}

	.service-item:last-child {
		border-bottom: none;
	}

	.service-info {
		flex: 1;
	}

	.service-name {
		font-size: 28rpx;
		color: #333;
		font-weight: 500;
		display: block;
		margin-bottom: 6rpx;
	}

	.service-desc {
		font-size: 24rpx;
		color: #999;
	}

	.service-price {
		font-size: 28rpx;
		color: #ff6b6b;
		font-weight: 600;
	}

	/* 订单信息列表 */

	.info-item {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 18rpx 0;
		border-bottom: 1px solid #f5f5f5;
	}

	.info-item:last-child {
		border-bottom: none;
	}

	.info-item.total-item {
		background: linear-gradient(135deg, #fff7e6 0%, #fff2cc 100%);
		margin: 15rpx -30rpx;
		padding: 20rpx 30rpx;
		border-radius: 12rpx;
		border: none;
	}

	.info-label {
		font-size: 26rpx;
		color: #666;
	}

	.info-value {
		font-size: 26rpx;
		color: #333;
		text-align: right;
		font-weight: 500;
	}

	/* 特殊样式 */
	.discount {
		color: #ff4d4f;
	}

	.total {
		color: #ff6b6b;
		font-weight: 600;
		font-size: 30rpx;
	}

	.unverify {
		color: #999;
	}

	.verified-time {
		color: #52c41a;
		font-weight: 500;
	}

	/* 按钮容器 */
	.button-container {
		padding: 20rpx 20rpx 50rpx;
	}

	/* 确认核销按钮 */
	.verify-btn {
		width: 100%;
		background: linear-gradient(135deg, #2a8cff 0%, #764ba2 100%);
		color: #fff;
		font-size: 32rpx;
		padding: 25rpx 0;
		border-radius: 25rpx;
		box-shadow: 0 8rpx 32rpx rgba(102, 126, 234, 0.3);
		transition: all 0.3s ease;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.verify-btn text {
		margin-left: 12rpx;
	}

	.verify-btn:active {
		transform: translateY(2rpx);
		box-shadow: 0 4rpx 16rpx rgba(102, 126, 234, 0.4);
	}

	/* 已核销按钮 */
	.verified-btn {
		width: 100%;
		background: linear-gradient(135deg, #f0f0f0 0%, #e8e8e8 100%);
		color: #999;
		font-size: 32rpx;
		padding: 25rpx 0;
		border-radius: 25rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.verified-btn text {
		margin-left: 12rpx;
	}
</style>